package com.ruoyi.basedata.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.basedata.domain.WfzXcxmaccont;
import com.ruoyi.basedata.service.IWfzXcxmaccontService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 薪酬项目与会计科目对照Controller
 * 
 * @author xiefeng
 * @date 2022-12-12
 */
@RestController
@RequestMapping("/basedata/xcxmaccont")
public class WfzXcxmaccontController extends BaseController
{
    @Autowired
    private IWfzXcxmaccontService wfzXcxmaccontService;

    /**
     * 查询薪酬项目与会计科目对照列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:xcxmaccont:list')")
    @GetMapping("/list")
    public TableDataInfo list(WfzXcxmaccont wfzXcxmaccont)
    {
        startPage();
        List<WfzXcxmaccont> list = wfzXcxmaccontService.selectWfzXcxmaccontList(wfzXcxmaccont);
        return getDataTable(list);
    }

    /**
     * 导出薪酬项目与会计科目对照列表
     */
    @PreAuthorize("@ss.hasPermi('basedata:xcxmaccont:export')")
    @Log(title = "薪酬项目与会计科目对照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WfzXcxmaccont wfzXcxmaccont)
    {
        List<WfzXcxmaccont> list = wfzXcxmaccontService.selectWfzXcxmaccontList(wfzXcxmaccont);
        ExcelUtil<WfzXcxmaccont> util = new ExcelUtil<WfzXcxmaccont>(WfzXcxmaccont.class);
        util.exportExcel(response, list, "薪酬项目与会计科目对照数据");
    }

    /**
     * 获取薪酬项目与会计科目对照详细信息
     */
    @PreAuthorize("@ss.hasPermi('basedata:xcxmaccont:query')")
    @GetMapping(value = "/{fid}")
    public AjaxResult getInfo(@PathVariable("fid") Long fid)
    {
        return success(wfzXcxmaccontService.selectWfzXcxmaccontByFid(fid));
    }

    /**
     * 新增薪酬项目与会计科目对照
     */
    @PreAuthorize("@ss.hasPermi('basedata:xcxmaccont:add')")
    @Log(title = "薪酬项目与会计科目对照", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WfzXcxmaccont wfzXcxmaccont)
    {
        wfzXcxmaccont.setFcreator(getUsername());
        wfzXcxmaccont.setFlastupdateuser(getUsername());
        return toAjax(wfzXcxmaccontService.insertWfzXcxmaccont(wfzXcxmaccont));
    }

    /**
     * 修改薪酬项目与会计科目对照
     */
    @PreAuthorize("@ss.hasPermi('basedata:xcxmaccont:edit')")
    @Log(title = "薪酬项目与会计科目对照", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WfzXcxmaccont wfzXcxmaccont)
    {
        wfzXcxmaccont.setFlastupdateuser(getUsername());
        return toAjax(wfzXcxmaccontService.updateWfzXcxmaccont(wfzXcxmaccont));
    }

    /**
     * 删除薪酬项目与会计科目对照
     */
    @PreAuthorize("@ss.hasPermi('basedata:xcxmaccont:remove')")
    @Log(title = "薪酬项目与会计科目对照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{fids}")
    public AjaxResult remove(@PathVariable Long[] fids)
    {
        return toAjax(wfzXcxmaccontService.deleteWfzXcxmaccontByFids(fids));
    }
}
